package com.example.demo.controller.rmqp2;

import com.example.demo.controller.rmqp.RmqpConnection;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * @author 高俊
 * @create 2021-08-2021/8/14-17:13
 */
public class RmqpProduct {

    public static void main(String[] args) throws Exception {
        Channel connection = RmqpConnection.getConnection();


        // 创建队列
        connection.queueDeclare(RmqpConnection.NEW_QUENE,false,false,false,null);

        System.out.print("输入消息：");
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String message = scanner.next();
            System.out.print("输入消息：");
            // 发送消息
            connection.basicPublish("",RmqpConnection.NEW_QUENE,null,message.getBytes("UTF-8"));
            System.out.println("发送完成.......");
        }



    }
}
